2015-09-30(胡工).sql 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'View_tb_ErpProduct')
  2. BEGIN
  3. DROP VIEW [dbo].View_tb_ErpProduct
  4. END
  5. GO
  6. create View View_tb_ErpProduct
  7. as
  8. select tb_ErpProduct.ID,Prod_AlarmQuantity,
  9. Prod_Number,Prod_DividedShop,
  10. Prod_Name,Prod_Class,Prod_Unit,
  11. Prod_CostPrice,
  12. Prod_SalesPrice,
  13. Prod_SpecialPrice,
  14. Prod_PurchasePrice,
  15. Prod_IsRetail,
  16. Prod_IsEnabled,
  17. Prod_Introduction,
  18. Prod_Detail,
  19. Prod_Remark,
  20. Prod_Quantity,
  21. Prod_Thumbnail,
  22. Prod_FullSizeImage,
  23. Prod_Expedited,
  24. Prod_CreateDatetime,
  25. Prod_UpdateDatetime,
  26. Prod_Batch,
  27. Prod_ClassName,
  28. Sc_ClassCode,
  29. Sc_ClassName,
  30. Sc_ClassParentID,
  31. Sc_ClassRemark,
  32. Sc_IsDisable,
  33. Sc_IsReadOnly,
  34. Sc_URL,
  35. Sc_IsEnabledURL,
  36. Sc_CreateDatetime,
  37. Sc_UpdateDatetime,
  38. Sc_IsDelete ,
  39. Prod_IsEnabledName=CASE tb_ErpProduct.Prod_IsEnabled WHEN 1 THEN '上架' ELSE '下架' END ,
  40. dbo.fn_GetClassCodeToName(Prod_Class,Prod_ClassName) as Prod_ClassName2,
  41. (select Count(OPlist_ProdQuantity) from tb_ErpOrderProductList where OPlist_ProdNumber =Prod_Number and OPlist_Type = '2' and ((CONVERT(int,OPlist_CompletedStatus)+CONVERT(int,OPlist_PickupStatus))=0)) as Prod_PreSaleQuantity
  42. ,Prod_Availability
  43. from tb_ErpProduct left join tb_ErpSystemCategory on tb_ErpProduct.Prod_Class=tb_ErpSystemCategory.Sc_ClassCode
  44. GO